package org.example.com.editor.io;

import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

public class FileIOUtil {
    public static List<String> readFile(String filePath){
        try{
            return Files.readAllLines(Paths.get(filePath), StandardCharsets.UTF_8);
        } catch (java.io.IOException e) {
            System.out.println("读取文件失败: " + e.getMessage());
            return new ArrayList<>();
        }
    }


    public static void writeFile(String filePath, List<String> content){
        try{
            Files.write(Paths.get(filePath), content,StandardCharsets.UTF_8);
        } catch (java.io.IOException e) {
            System.out.println("读取文件失败: " + e.getMessage());
        }
    }
}
